<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>文件上传</title>
<script type="text/javascript">
function upload(locimage,fileInputId,returnShowId){
	var FileType = "jpg,png,gif,rar,zip,word,wordx,ppt,pptx,pdf,text,xls,xlsx"; 
    var FileName = locimage.value;
    FileName = FileName.substring(FileName.lastIndexOf('.')+1, FileName.length).toLowerCase(); 
    if (FileType.indexOf(FileName) == -1)
     {
    	$('#'+fileInputId).val("");
    	alert('请选择jpg,png,gif,rar,zip,word,wordx,ppt,pptx,pdf,text,xls,xlsx格式文件!');
     }else{
    	 uploadopt(FileName,fileInputId,returnShowId,"");
     }
}
function uploadopt(FileName,fileInputId,returnShowId,value){
	var imageFileNametoreuqest=new Date().getTime()+"."+FileName;
	var url='fileUpload!fileUpload.action?imageFileNametoreuqest='+imageFileNametoreuqest;
	$.ajaxFileUpload({
		url:url,
		secureuri:false,
        fileElementId:fileInputId,
        dataType:'String',
		success: function (data){
			alert('上传成功!');
			$('#'+fileInputId).val("");
			$('#'+returnShowId).text("upload/"+imageFileNametoreuqest);
		},
		error: function (data, status){
			alert('上传失败!');
        }
	});
}

</script>
</head>
<body>
<div id="add_news" title="文件上传" class="easyui-panel" fit="true" border="none" style="padding:3px;">
<input type="file" id="upload_file" onchange="upload(this,'upload_file','upload_opt_info')" name="myFile"/>
<br>
请复制以下链接插入到相应的位置：
<span id="upload_opt_info"></span>
</div>
</body>
</html>